std.boolean
Pebble 0.3.1 · all symbols on this page are stable.
Monomorphic helpers over bool. Prefer the operator forms (&&, ||, !) in regular code — these exist for partial application and higher-order use.
Methods
| Function | Description |
|---|---|
not(b: bool): bool | Logical NOT. |
strictAnd(a: bool, b: bool): bool | Logical AND. Strict in both arguments — unlike && which short-circuits, both a and b are evaluated. |
strictOr(a: bool, b: bool): bool | Logical OR. Strict in both arguments — unlike ||. |
equals(a: bool, b: bool): bool | True iff a and b have the same value. |
toInt(b: bool): int | 0 for false, 1 for true. |
Strict vs short-circuit
strictAnd / strictOr evaluate both operands. If either argument can fail or perform an expensive computation, use the operator forms && / || which short-circuit.
Examples
using { not, strictAnd, strictOr, equals, toInt } = std.boolean;
const n: bool = not(true); // false
const a: bool = strictAnd(true, false); // false
const o: bool = strictOr(true, false); // true
const eq: bool = equals(true, true); // true
const i: int = toInt(true); // 1
See also
bool— operator formsstd.builtins—ifThenElseis the strict polymorphic conditional